var g = {
    cfgAxios: function() {
        axios.defaults.baseURL = locationCfg.remote;
        axios.interceptors.request.use(function(config) {
            g.lockAllInput();
            g.lockAllButton();
            $.AMUI.progress.start();
            $.AMUI.progress.inc();
            return config;
        }, function(error) {
            return Promise.reject(error);
        });
        axios.interceptors.response.use(function(response) {
            g.unLockAllInput();
            g.unLockAllButton();
            $.AMUI.progress.done();
            return response;
        }, function(error) {
            return Promise.reject(error);
        });
    },

    lockAllInput: function() {
        var allInput = $('input');
        _.forEach(allInput, function(value, key) {
            var $element = $(value);
            $element.attr('disabled', 'disabled');
        });
    },
    unLockAllInput: function() {
        var allInput = $('input');
        _.forEach(allInput, function(value, key) {
            var $element = $(value);
            $element.removeAttr('disabled');
        });
    },
    lockAllButton: function() {
        var allInput = $('button');
        _.forEach(allInput, function(value, key) {
            var $element = $(value);
            $element.attr('disabled', 'disabled');
        });
    },
    unLockAllButton: function() {
        var allInput = $('button');
        _.forEach(allInput, function(value, key) {
            var $element = $(value);
            $element.removeAttr('disabled');
        });
    },
    handleResponse: function(res, fuc1, fuc2) {
        res.Success == true ? fuc1(res) : fuc2(res);
    }
};

g.cfgAxios();